import { defineStore } from "pinia";
import { useOrderInfoApi } from "@/utils/api/orderInfoApi";

export const useOrdersStore = defineStore("orderStore",{
    state:()=>({
        ordersInfo:[]
    }),

    getters:{
        stateOrder:(state:any)=>{
            return state.ordersInfo
        }
    },
    actions:{
        //获取所有订单信息
        async getALlOrderInfo(){
            try{
                const {response,error,fatchData} =  await useOrderInfoApi('/order','get')
                await fatchData()
                if(response.value){
                    this.ordersInfo = response.value as typeof this.ordersInfo
                }
            }catch(err){
                console.log("请求失败")
                return err
            }
        }
    }
})